package service

import (
	"ruoyi-go/app/admin/model/system"
	"ruoyi-go/pkg/mysql"
)

var SysRoleDeptService = &sysRoleDeptService{}

type sysRoleDeptService struct{}

// 删除角色与部门关联
func (sysRoleDeptService) DeleteRoleDept(roleIds string) {
	sql := "delete from sys_role_dept where role_id in ( " + roleIds + " )"
	err := mysql.MysqlDb().Exec(sql).Error
	if err != nil {
		panic(err.Error())
	}
}

func (sysRoleDeptService) DeleteRoleDeptByRole(roleId string) {
	err := mysql.MysqlDb().Where("role_id = ?", roleId).Delete(&system.SysRoleDept{}).Error
	if err != nil {
		panic(err.Error())
	}
}
